<?php
/**
 *	KLF Framework
 *
 *	Written by Kristian Oye <kristianoye@gmail.com> on Dec 18, 2011
 *	Copyright (C) 2010-2011
 */
namespace KLF\System\Web\MVC
{
	use KLF\System\KObject;
	use KLF\System\Web\Routing\KRouteContext;
	use KLF\System\Web\Routing\KRouteCollection;
	
	/**
	 *  Class KUrlHelper
	 *
	 *  A KUrl helper to assist in rendering views and building actions.
	 *
	 *  @package KLF\System\Web\MVC
	 *  @access public
	 *  @author Kristian Oye <kristianoye@gmail.com>
	 *  @since 0.1
	 *
	 *  @method KUrlHelper NewInstance
	 *  
	 *  @property KRouteContext $Context
	 *  @property KRouteCollection $Routes
	 */
	class KUrlHelper extends KObject
	{
		/**
		 * The currently executing context.
		 * 
		 * @var KRouteContext $_rpropContext
		 */
		protected $_rpropContext;
		
		/**
		 * A collection of routes.
		 * 
		 * @var KRouteCollection $_rpropRoutes
		 */
		protected $_rpropRoutes;
		
		/**
		 * Construct a new URL helper object.
		 * 
		 * @param KRouteContext $context
		 * @param KRouteCollection $routes
		 */
		public function __construct(KRouteContext $context, KRouteCollection $routes = null)
		{
			$this->_rpropContext = $context;
			$this->_rpropRoutes = $routes;			
		}
		
		/**
		 * Constructs an action URL.
		 */
		public function Action($parms)
		{
			if (is_array($parms = func_lower_args($parms)))
			{
				return "http://www.notimplemented.com/";
			}
		}
		
		/**
		 * TODO: Fix this
		 * 
		 * Creates a URL path to a static resource.
		 * 
		 * @param string $path
		 */
		public function Content($path)
		{
			return $path;
		}
		
		/**
		 * Encode a string.
		 * 
		 * @param string $strIn
		 * @return string
		 */
		public function Encode($strIn)
		{
			return urlencode($strIn);
		}
		
		/**
		 * TODO: Fix this
		 * 
		 * Generates a URL that maps to a route.
		 *
		 * @author: Kristian Oye <kristianoye@gmail.com>
		 * @since 0.1
		 * @return string The route
		*/
		public function Route()
		{
			if (is_array($parms = func_lower_args($parms)))
			{
				return "http://www.notimplemented.com/";
			}
		}
	}
}
